#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define PATH "/dev/VirtualDisk"
#define BUFSIZE 0x2000

int main(int argc, char **argv)
{
    if (argc != 2)
    {
        printf("you should put one args\n");
        exit(1);
    }
    int fd;
    static const char buf[20] = "hello ,world.";
    static char getbuf[BUFSIZE];
    fd = open(PATH, O_RDWR);
    if(fd<0)
    {
        perror("open failed");
        exit(1);
    }
    write(fd , buf, sizeof(buf));
    lseek(fd, 0, SEEK_SET);
    read(fd , getbuf, sizeof(buf));
    printf("read from %s is [%s]\n", PATH, getbuf);
    ioctl(fd, atoi(argv[1]));
    close(fd);
    return 0;
}